#include <bits/stdc++.h>
using namespace std;
const int SIZE = 100005;

struct Node{
    int value;
    int index;
    Node* prev;
    Node* next;
};
int n;
int a[SIZE];

Node* pos[SIZE];
int ans[SIZE];

Node* AddNode(Node* node, int index) {
    Node* NewNode = new Node();
    NewNode->index = index;
    NewNode->value = a[index];
    node->next->prev = NewNode;
    NewNode->next = node->next;
    NewNode->prev = node;
    node->next = NewNode;
    return NewNode;


}

void DelNode(Node* node) {
    node->prev->next = node->next;
    node->next->prev = node->prev;
    delete node;

}
int main() {
    int rank[SIZE];
    // 读取个数
    cin >> n;
    // 读取输入序列至a[]
    // 建立排序数组，存储输入顺序，对应a[]的下标
    for (int i =1; i <= n; i++) {
        scanf("%d", &a[i]);
        rank[i] = i;
    }
    // a = [1, 5, 3, 4, 2]
    // rank = [1, 5, 3, 4, 2]
    //         a[1], a[5], a[3], a[4], a[2]
    //a[rank] = [1, 2, 3, 4, 5]
    // a[rank[1]], a[rank[2]],..., a[rank[n]]
    // 排序 lambda 表达式, 从1开始
    //printf("Before sort: a[rank[1]]=%d a[rank[2]]=%d\n", a[rank[1]], a[rank[2]]);
    
    sort(rank+1, rank+n+1, [&](int ranki, int rankj) {return a[ranki] < a[rankj];});
    // 设保护节点
    Node head;
    Node tail;
    head.next = &tail;
    tail.prev = &head;
    //printf("After sort: a[rank[1]]=%d a[rank[2]]=%d\n", a[rank[1]], a[rank[2]]);
    head.value = a[rank[1]] - 1e9;
    //printf("%d\n", head.value);
    tail.value = a[rank[n]] + 1e9;
    //printf("%d\n", tail.value);
    
    for (int i = 1; i <=n; i++) {
        //printf("i=%d, rank[%d]=%d\n", i, i,rank[i]);
        pos[rank[i]] = AddNode(tail.prev, rank[i]);
    }

/*
    for (int i = 1; i <=n; i++) {
        printf("i=%d, rank[%d]=%d pos[rank[%d]]=%p, index=%d, value=%d\n", i, i,rank[i],i,pos[rank[i]], pos[i]->index, pos[i]->value);
    }
*/
  //  printf("pos[%d]=%d, pos[%d]=%d\n", pos[1]->index,pos[1]->value, pos[2]->index, pos[2]->value);
    for (int i = n; i > 1; i--) {
        Node* cur = pos[i];
        
    //    printf("prev->index=%d, prev->value=%d\n", cur->prev->index, cur->prev->value);
      //  printf("a[i]-cur->prev->value=%d, cur->next-value - a[i]=%d\n", a[i]-cur->prev->value, cur->next->value-a[i]);
        // 后继和前驱谁和a[i]的距离较小？
        if (a[i]- cur->prev->value <= cur->next->value - a[i]){
            if(cur->prev->index != 0) ans[i] = cur->prev->index;// 已超出边界，prev 指向head
            else ans[i] = cur->next->index;
        //    printf("Here\n");
          //  printf("i=%d ans[i]=%d\n", i, ans[i]);
        } else {
            if (cur->next->index !=0) ans[i] = cur->next->index; // 已超出边界，next 指向tail了
            else ans[i] = cur->prev->index;
            //printf("Else\n");
        }
        DelNode(cur);
    }
    for (int i = 2; i<=n; i++) {
        //printf("i=%d, a[ans[i]]=%d, a[i]=%d, distance=%d ans[i]=%d\n", i, a[ans[i]], a[i], abs(a[ans[i]]-a[i]), ans[i]);
        printf("%d %d\n", abs(a[ans[i]]- a[i]), ans[i]);
    }
}